<template>
    <sc-table-select
        placeholder="---请选择---"
        ref="tableselect"
        v-model="orgcodevalue"
        style="width: 300px"
        :pageId="pageId"
        :userCode="userCode"
        :purviewType="purviewType"
        :attrList="attrList"
        :valueList="valueList"
        :queryList="queryList"
        :orderList="orderList"
        :table-width="640"
        :multiple="multiple" 
        :queryType="queryType"
        selectType="org"
        collapse-tags
        collapse-tags-tooltip
        :props="props"
        :selectKeyValue="selectKeyValue"
        @change="change"
        @remove-tag="removeTag" 
    >
        <!-- collapse-tags
        collapse-tags-tooltip-->
        <template #header="{}">
            <el-form :inline="true" style="margin-bottom: 10px;">
                <el-row :gutter="5">
                    <el-col :span="5">
                        <el-input v-model="queryList.supplierCode" placeholder="请输入编码" style="width: 125px" @keyup.enter="$refs.tableselect.getData()"></el-input>
                    </el-col>
                    <el-col :span="5">
                        <el-input v-model="queryList.supplierName" placeholder="请输入名称" style="width: 125px" @keyup.enter="$refs.tableselect.getData()"></el-input>
                    </el-col>
                    <el-col :span="5">
                        <el-select
                            v-model="queryList.State"
                            placeholder="请选择状态" 
                            clearable
                            :teleported="false"
                            style="width: 125px"
                        >
                            <el-option label="---请选择状态---" value />
                            <el-option label="禁用" value="0" />
                            <el-option label="启用" value="1" />
                        </el-select>
                    </el-col>
                    <el-col :span="4">
                        <el-button type="primary" @click="$refs.tableselect.getData()">查询</el-button>
                    </el-col>
                </el-row>
            </el-form>
        </template>
        <el-table-column prop="supplierCode" label="机构编码" width="100"></el-table-column>
        <el-table-column prop="supplierName" label="机构名称" width="150" show-overflow-tooltip></el-table-column>
        <el-table-column prop="realName" label="联系人" width="90"></el-table-column>
        <el-table-column prop="mobile" label="手机号" width="120"></el-table-column>
		<el-table-column prop="address" label="地址" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column prop="statusDesc" label="状态" width="100"></el-table-column>
    </sc-table-select>
</template>

<script>
import tool from "@/utils/tool";
import bus from "@/utils/mitt";
export default {
    name: "orgselect",
    props: {
        pageId: { type: String, default: "" },
        multiple: { type: Boolean, default: true },
        userCode: { type: String, default: "super" },
        purviewType: { type: String, default: "super" },
        selectKeyValue: { type: String, default: "Code" },
        queryType: { type: String, default: "supplier/pages" },
        defaultQueryList: { type: Object, default: {} },
    },
    data() {
        return {
            //queryType: "supplier/pages",
            hideClearBtn: true,
            attrList: {},
            valueList: {},
            queryList: {},
            //apiObj: this.$API.demo.page,
            params: {
                name: "demoName",
            },
            orgcodevalue: [],
            props: {
                label: "supplierName",
                value: "supplierId",
                keyword: "keyword",
            },
            formatType(row, column) {
                // eslint-disable-next-line no-debugger
                ////debugger;
                console.log(row, column);
                switch (row.TypeCode) {
                    case "01":
                        return "直营店";
                    case "02":
                        return "加盟店";
                    default:
                        return "";
                }
            },
            lastOrgVal: [],
        };
    },
    computed: {},
    async mounted() {
        await this.opBindData();
    },
    methods: {
        async opBindData() {
            this.queryList={...this.queryList,...this.defaultQueryList}
            this.$nextTick(() => {
                this.$refs.tableselect.getData();
            });
           
        },
        //值变化
        change(val) {
            if (Array.isArray(val)) {
                if (val.length == 0) {
                    this.$emit("fatherMethod", []);
                } else {
                    this.$emit("fatherMethod", val);
                }
            } else {
                if (val) {
                    this.$emit("fatherMethod", val);
                }
            }
        },
    },
};
</script>

<style>
.custom-org-el-select-close .el-tag__close {
    display: none !important;
}
</style>
